<?php

declare(strict_types=1);

namespace app\common\model;

/**
 * @mixin \think\Model
 */
class Admin extends Base
{
    protected $pk = 'admin_id';
    public function getHeadImgUrlAttr($value, $data)
    {
        if (empty($data['head_img'])) {
            return '';
        } else {
            $resourceRow = app('resource')->getImgPath(['code' => $data['head_img']]);
            if (!empty($resourceRow)) {
                return $resourceRow['thumbnail_url']; //此处设置使用缩略图
            } else {
                return '';
            }
        }
    }

    public function getLastTimeAttr($value)
    {
        if (!empty($value)) {
            return date('Y-m-d H:i', $value);
        } else {
            return '';
        }
    }
}
